library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
l_df <- read_csv("levels-cleaned.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## .default = col_double(),
## timestamp = col_character(),
## company = col_character(),
## level = col_character(),
## title = col_character(),
## location = col_character(),
## tag = col_character(),
## gender = col_character(),
## city = col_character(),
## state = col_character(),
## month = col_character()
## )
## See spec(...) for full column specifications.
companyCompensation <-
l_df %>%
group_by(year, company) %>%
summarise(yearly_compensation = mean(totalyearlycompensation))
## `summarise()` regrouping output by 'year' (override with `.groups` argument)
cityCompensation <-
l_df %>%
group_by(year, location) %>%
summarise(yearly_compensation = mean(totalyearlycompensation))
## `summarise()` regrouping output by 'year' (override with `.groups` argument)
Yearly mean compensation for top 5 companies in 2017, 2018, 2019, 2020, 2021
companyCompensation2017 <-
companyCompensation %>%
filter(year == 2017) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2018 <-
companyCompensation %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2019 <-
companyCompensation %>%
filter(year == 2019) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2020 <-
companyCompensation %>%
filter(year == 2020) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2021 <-
companyCompensation %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(companyCompensation2017, companyCompensation2018, companyCompensation2019, companyCompensation2020, companyCompensation2021, nrows = 5)
Yearly mean compensation for top 5 cities in 2017, 2018, 2019, 2020, 2021
cityCompensation2017 <-
cityCompensation %>%
filter(year == 2017) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018 <-
cityCompensation %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2019 <-
cityCompensation %>%
filter(year == 2019) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2020 <-
cityCompensation %>%
filter(year == 2020) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021 <-
cityCompensation %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2017, cityCompensation2018, cityCompensation2019, cityCompensation2020, cityCompensation2021, nrows = 5)
Yearly mean compensation for last 5 companies in 2017, 2018, 2019, 2020, 2021
companyCompensation2017 <-
companyCompensation %>%
filter(year == 2017) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2018 <-
companyCompensation %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2019 <-
companyCompensation %>%
filter(year == 2019) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2020 <-
companyCompensation %>%
filter(year == 2020) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
companyCompensation2021 <-
companyCompensation %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~company,
type = "bar",
text = ~paste(company, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(companyCompensation2017, companyCompensation2018, companyCompensation2019, companyCompensation2020, companyCompensation2021, nrows = 5)
Yearly mean compensation for last 5 cities in 2017, 2018, 2019, 2020, 2021
cityCompensation2017 <-
cityCompensation %>%
filter(year == 2017) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018 <-
cityCompensation %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2019 <-
cityCompensation %>%
filter(year == 2019) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2020 <-
cityCompensation %>%
filter(year == 2020) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021 <-
cityCompensation %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2017, cityCompensation2018, cityCompensation2019, cityCompensation2020, cityCompensation2021, nrows = 5)
Making YOE Levels
YOE_Levels <-
l_df %>%
mutate(YOE = case_when(between(yearsofexperience, 0, 2) ~ "0-2",
between(yearsofexperience, 2, 5) ~ "2-5",
between(yearsofexperience, 5, 10) ~ "5-10",
yearsofexperience >= 10 ~ "10+"))
cityCompensationYOE <-
YOE_Levels %>%
group_by(year, YOE, location) %>%
summarise(yearly_compensation = mean(totalyearlycompensation))
## `summarise()` regrouping output by 'year', 'YOE' (override with `.groups` argument)
2018 top 5 locations with experience plots
cityCompensation2018_01 <-
cityCompensationYOE %>%
filter(YOE == "0-2") %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_15 <-
cityCompensationYOE %>%
filter(YOE == "2-5") %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_510 <-
cityCompensationYOE %>%
filter(YOE == "5-10") %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_10_ <-
cityCompensationYOE %>%
filter(YOE == "10+") %>%
filter(year == 2018) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2018_01, cityCompensation2018_15, cityCompensation2018_510, cityCompensation2018_10_, nrows = 4)
2021 top 5 locations with experience plots
cityCompensation2021_01 <-
cityCompensationYOE %>%
filter(YOE == "0-2") %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_15 <-
cityCompensationYOE %>%
filter(YOE == "2-5") %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_510 <-
cityCompensationYOE %>%
filter(YOE == "5-10") %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_10_ <-
cityCompensationYOE %>%
filter(YOE == "10+") %>%
filter(year == 2021) %>%
arrange(desc(yearly_compensation)) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2021_01, cityCompensation2021_15, cityCompensation2021_510, cityCompensation2021_10_, nrows = 4)
2018 last 5 locations with experience plots
cityCompensation2018_01 <-
cityCompensationYOE %>%
filter(YOE == "0-2") %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_15 <-
cityCompensationYOE %>%
filter(YOE == "2-5") %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_510 <-
cityCompensationYOE %>%
filter(YOE == "5-10") %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2018_10_ <-
cityCompensationYOE %>%
filter(YOE == "10+") %>%
filter(year == 2018) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2018_01, cityCompensation2018_15, cityCompensation2018_510, cityCompensation2018_10_, nrows = 4)
2021 last 5 locations with experience plots
cityCompensation2021_01 <-
cityCompensationYOE %>%
filter(YOE == "0-2") %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_15 <-
cityCompensationYOE %>%
filter(YOE == "2-5") %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_510 <-
cityCompensationYOE %>%
filter(YOE == "5-10") %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
cityCompensation2021_10_ <-
cityCompensationYOE %>%
filter(YOE == "10+") %>%
filter(year == 2021) %>%
arrange(yearly_compensation) %>%
head(n = 5) %>%
plot_ly(
x = ~yearly_compensation,
y = ~location,
type = "bar",
text = ~paste(location, ": $", round(yearly_compensation), sep = ""),
hoverinfo = "text"
) %>%
layout(showlegend = FALSE)
subplot(cityCompensation2021_01, cityCompensation2021_15, cityCompensation2021_510, cityCompensation2021_10_, nrows = 4)